// 菜单管理模块的接口

// 导入请求函数
import request from "@/utils/request";

// 导入相关的类型
import type { PermissionResponseData, MenuParams } from "./type";

// 枚举地址
enum API {
    // 获取全部菜单与按钮的标识数据
    ALLPERMISSION_URL = '/admin/acl/permission',
    // 给某一级菜单新增一个子菜单
    ADDMENU_URL = '/admin/acl/permission/save',
    // 更新某一菜单
    UPDATEMENU_URL = '/admin/acl/permission/update',
    // 删除某一菜单
    REMOVEMENU_URL = '/admin/acl/permission/remove/',
}
// 获取菜单的数据
export const reqAllPermission = () => request.get<any, PermissionResponseData>(API.ALLPERMISSION_URL)
// 添加与更新菜单的方法
export const reqAddOrUpdateMenu = (data: MenuParams) => {
    if (data.id) {
        return request.put<any, any>(API.UPDATEMENU_URL, data)
    } else {
        return request.post<any, any>(API.ADDMENU_URL, data)
    }
}
// 删除某一菜单
export const reqRemmoveMenu = (menuId: number) => request.delete(API.REMOVEMENU_URL + menuId)